10-19-2014

Goals

  • Provide an overview of PsychoPy2
    • What is it?
    • How does it work?


  • Why you should care
    • Gain better understanding of psycholinguistic experiments

Goals

  • What will you learn?
    • You will be able to create your own simple experiment
    • You will have the resources to create more complicated experiments

Plan

  • Overview of PsychoPy2
  • Demo
  • Using PsychoPy2 - the interface
  • Creating a simple experiment - Stroop task
  • Dealing with results
  • Concluding ideas

Overview

  • What is it?
    • PsychoPy2 is a free program made in Python
    • It can be used to create experiments in psychology, psychophysics, neuroscience and linguistics.
  • Why do you want it?
    • It's free!
    • It's cross-platform
    • It has a GUI (builder mode) or you can write in code

  • What is it good for?
    • PsychoPy2 can be used to create psycholinguistic tasks:
      • 2AFC
      • AX, AXB, ABX
      • Lexical decision (masked prime)
      • even production experiments
  • What is it not good for?
    • ?

Getting started

Examples

Risky business

  • Balloon Analogue Risk Task (BART) (Lejuez et al., 2002)
  • The measure is designed to quantify individual differences in risk-taking.

Mental rotation


  • Cognitive task related to mental representations of objects (Gray & Pasmanter, 2013)



A linguistic experiment


  • 2AFC
  • Interested in perception of non-native vowel contrasts
    • What acoustic cues do late-learners of English use to perceive tense/lax contrasts?
    • Spectrum? Duration?
  • /i/-/ɪ/

The stimuli

  • 11-step spectrum continuum
  • 11-step duration continuum

Results

The interface

The interface (Coder mode)

import itertools

def iter_primes():
     # an iterator of all numbers between 2 and +infinity
     numbers = itertools.count(2)

     # generate primes forever
     while True:
         # get the first number from the iterator
         prime = numbers.next()
         yield prime
for p in iter_primes():
    if p > 1000:
        break
    print p

The interface (Builder mode)

  • Provides a graphical user interface
  • Linear representation of experiment 'flow'
  • Row view of routine components

The interface (Experiment flow)

  • The experiment advances linearly from left to right
  • Each element (a routine) finishes before advancing
  • Similar to slides in a power point

Routines

  • Individual view of each 'slide'
  • Comprised of a series of components that perform a task

Components list

  • Stimuli
    • Text/Audio/Images/Video
  • Responses
    • Keyboard, lykert scales, button boxes, mouse tracking, eye tracking, microphone
  • Custom
    • Python code

Demo

How to build your own experiment

  • Decide what you want to do
  • Find a similar template
  • Choose variables
  • Create loops

Stroop task

Stroop task

  1. Create a new folder 'stroop' on your desktop
  2. Launch Pyschopy2
    • Open new builder window
    • Save new experiment as 'stroop.psyexp' in the 'stroop' folder
  3. Select new keyboard response component

Stroop task

  1. Create a new folder 'stroop' on your desktop
  2. Launch Pyschopy2/Open new builder window
  3. Select new keyboard response component
  4. Select new text stimuli component

Stroop task

  1. Create a new folder 'stroop' on your desktop
  2. Launch Pyschopy2/Open new builder window
  3. Select new keyboard response component
  4. Select new text stimuli component
  5. Create condition file
    • Open excel (or text editor)
    • Create 'text' column
    • Create 'color' column
    • Create 'corrAns' column
    • Create 'congruent' column



Stroop task

  1. Create a new folder 'stroop' on your desktop
  2. Launch Pyschopy2/Open new builder window
  3. Select new keyboard response component
  4. Select new text stimuli component
  5. Create condition file
  6. Save condition file in 'stroop' folder, create loop


Stroop task

  1. Create a new folder 'stroop' on your desktop
  2. Launch Pyschopy2/Open new builder window
  3. Select new keyboard response component
  4. Select new text stimuli component
  5. Create condition file
  6. Save condition file in 'stroop' folder, create loop
  7. Run experiment
  • You made an awesome experiment, collected data… now what?

Dealing with results

  • Specify the output format
  • Import results directly into stats program
# Set working directory
setwd("~/google_drive/14_fall_2014/proseminar/psychopy2_workshop")

# Combine files vertically into large data frame
temp <- list.files(path = "./demos/3_stroop/data", full.names = TRUE, pattern = ".csv")
myfiles <- lapply(temp, read.csv,sep = ",")
df <- do.call("rbind",myfiles)

Plots

Plots

Statistics

mod <- glm(resp.corr ~ letterColor, data = df, family = "binomial")
Estimate Std. Error z value Pr(>|z|)
(Intercept) 1.83 0.29 6.34 0.00
letterColorgreen -1.26 0.35 -3.57 0.00
letterColorred 0.64 0.47 1.36 0.17

Conclusion

  • You now know the basics of Pyschopy2
    • Can be used to create simple psycholinguistic experiments
    • Provided templates can be modified to create more complex experiments

Conclusion

  • Pros
    • Free
    • Allows for control over everything
    • Easy to streamline into research workflow
  • Cons
    • Complicated?
    • Ugly?

More resources

References

  • Gray, J. & Pasmanter, N. (2013). github
  • Lejuez, C. W., Aklin, W. M., Zvolensky, M. J., & Pedulla, C. M. (2003). Evaluation of the Balloon Analogue Risk Task (BART) as a predictor of adolescent real-world risk-taking behaviours. Journal of adolescence, 26(4), 475-479.
  • McGuire, G. (2010, in progress) A Brief Primer on Experimental Designs in Speech Perception Research. http://people.ucsc.edu/~gmcguir1/
  • Simonet, M. (2012). El diseño de experimentos para el estudio de la percepción del habla. Laboratory Approaches to Romance Phonology Conference. El Colegio de México, México D.F.